<?php

class Dir 
{
	public static function get($dir, $fotos = NULL)
	{
		if ($handle = opendir($dir)) 		
		{
		    while (false !== ($file = readdir($handle))) 
		    {
		        if ($file != "." && $file != "..") 
		        {
		        	if(is_array($fotos))
		        	{
			    		if(in_array($file, $fotos))
			    		{
				            echo "<div class=\"lightD\">
					            	<a title=\"$file\" class=\"lightB\" href=\"/intranet/$dir$file\">
					            		<img title=\"$file\" class=\"img\" width=\"120px\" height=\"100px\" src=\"/intranet/$dir$file\" />
					            	</a>
					            	<br />
					            	<a href=\"#\" onclick=\"deleteFile('$dir$file')\">
					            		excluir
					            	</a>
					            	<br />
				            	</div>";
			    		}
		        	}
		        }
		    }
		    
	   		closedir($handle);
		}
	}
	
	public static function getArray($dir, $ext = NULL)
	{
		if ($handle = opendir($dir)) 		
		{
		    while (false !== ($file = readdir($handle))) 
		    {
		        if ($file != "." && $file != "..") 
		        {
		        	if($ext)
		        	{
		        		if(strstr($file, $ext))
		        		{
		      				$arr[] = $file;
		        		}
		        	}
		        	else
		        	{
						$arr[] = $file;		        		
		        	}
		        }
		    }
		    
	   		closedir($handle);
		}
		
		return $arr;
	}
}

?>
